﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Xml;
using System.Data;

using BLL;
using DAL;
using Models;
using Web.Old_App_Code;
using System.Collections;

using Gift.DAL;
using Gift.Model;

public partial class cn_UserControl_module_navigation : System.Web.UI.UserControl
{
    // Fields
    protected ArticleManager am = new ArticleManager();
    protected ArticleTypeManager atm = new ArticleTypeManager();
    protected CategoryManager cm = new CategoryManager();
    protected GoodsManager gm = new GoodsManager();
    protected PointsForManager pfm = new PointsForManager();
    protected string xmlPath = "/cn/xml/home.xml";
    readonly DALClass theClass = new DALClass();

    readonly Gift.DAL.DALShoppro theShoppro = new Gift.DAL.DALShoppro();
    Gift.Model.DB_Shoppro oShoppro = null;

    // Methods
    protected StringBuilder ModuleNavigationBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            DataRow current;
            XmlElement element;
            int num5;
            IEnumerator enumerator;
            XmlDocument document = new XmlDocument();
            document.Load(base.Server.MapPath(this.xmlPath));
            builder.AppendLine("<div class=\"new_por\">");
            builder.AppendLine(" <div class=\"title\">");
            builder.AppendLine("<div class=\"pro_menu\">");
            DataTable table = this.cm.GetCategoryByNavigationTypeAndLanguageVersionAndIsShow(1, "zh-CN", 1);
            int num = 0;
            enumerator = table.Rows.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    current = (DataRow)enumerator.Current;
                    builder.AppendLine(string.Concat(new object[] { "", (num == 0) ? "" : " | ", "<a href=\"/cn/channel.html?cid=", current["id"], "\">", current["categoryName"], "</a>" }));
                    num = 1;
                }
            
            builder.AppendLine("</div>");
            builder.AppendLine("<p><span class=\"t_name_1\">新品上市</span><span class=\"t_name_2\">NEW</span></p>");
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"info\">");
            builder.AppendLine("<div class=\"info_img_link\">");
            XmlNodeList childNodes = document.SelectSingleNode("home_ad/new/left").ChildNodes;
            foreach (XmlNode node in childNodes)
            {
                element = (XmlElement)node;
                builder.AppendLine("<a href=\"" + element.GetAttribute("url") + "\" target=\"_blank\"><img src=\"" + element.GetAttribute("src") + "\" alt=\"" + element.GetAttribute("alt") + "\" /></a>");
            }
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"info_link\">");
            string articleTypeId = this.atm.GetIdByTypeNameAndParentIdAndLanguageVersionAndIsShow("促销活动", this.atm.GetIdByTypeNameAndParentIdAndLanguageVersionAndIsShow("资讯中心", "00000000-0000-0000-0000-000000000000", "zh-CN", 1), "zh-CN", 1);
            DataTable atricleByArticleTypeIdAndTop = this.am.GetAtricleByArticleTypeIdAndTop(articleTypeId, 2);
            builder.AppendLine("<ul>");
            enumerator = atricleByArticleTypeIdAndTop.Rows.GetEnumerator();
            
                while (enumerator.MoveNext())
                {
                    current = (DataRow)enumerator.Current;
                    builder.AppendLine(string.Concat(new object[] { "<li><a href=\"/cn/news_center/news_detail.html?id=", current["id"], "\" title=\"", current["articleTilte"], "\">- ", (current["articleTilte"].ToString().Length > 15) ? (current["articleTilte"].ToString().Substring(0, 15) + "...") : current["articleTilte"], "</a></li>" }));
                }

            builder.AppendLine("</ul>");
            XmlNodeList list2 = document.SelectSingleNode("home_ad/new/right").ChildNodes;
            foreach (XmlNode node in list2)
            {
                element = (XmlElement)node;
                builder.AppendLine("<a href=\"" + element.GetAttribute("url") + "\" target=\"_blank\"><img src=\"" + element.GetAttribute("src") + "\" alt=\"" + element.GetAttribute("alt") + "\" /></a>");
            }
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"clear\"></div>");
            builder.AppendLine("<div class=\"info_list\">");
            builder.AppendLine("<ul>");
            DataTable table3 = theShoppro.GetList(7," isnew = 1 ").Tables[0];// this.gm.GetGoodsByIsNewAndIsShelvesAndTop(1, 1, 7);
            enumerator = table3.Rows.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    current = (DataRow)enumerator.Current;

                    string picUrl = System.Configuration.ConfigurationManager.AppSettings["ProductUrl"] + current["prosmallpic"];
                    builder.AppendLine("<li>");
                    builder.AppendLine(string.Concat(new object[] { "<a href=\"/cn/goods.html?id=", current["proid"], "\" title=\"", current["proname"], "\" name=\"#hoverinfo", current["proid"], "\" class=\"pro_img\"><img alt=\"", current["proname"], "\" src=\"", picUrl, "\" /></a>" }));
                    builder.AppendLine(string.Concat(new object[] { "<p title=\"", current["proname"], "\"><a href=\"/cn/goods.html?id=", current["proid"], "\" title=\"", current["proname"], "\">", (current["proname"].ToString().Length > 8) ? (current["proname"].ToString().Substring(0, 8) + "...") : current["proname"], "</a><span>市场价", string.Format("{0:C}", Convert.ToDecimal(current["saleprice"])), "</span><em>会员价：<strong>", string.Format("{0:C}", Convert.ToDecimal(current["marketprice"])), "</strong></em></p>" }));
                    builder.AppendLine(string.Concat(new object[] { "<div id=\"hoverinfo", current["proid"], "\" style=\"display: none;\"><img src=\"", picUrl, "\" alt=\"", current["proname"], "\" /><p><strong>", current["proname"], "</strong> <span>产品编号:", current["procode"], "</span> <span>会员价：<em>", string.Format("{0:C}", Convert.ToDecimal(current["saleprice"])), "</em></span><span><del>市场价", string.Format("{0:C}", Convert.ToDecimal(current["saleprice"])), "</del></span></p></div>" }));
                    builder.AppendLine("</li>");
                }

            builder.AppendLine("</ul>");
            builder.AppendLine("<div class=\"clear\"></div>");
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            DataTable table4 = theShoppro.GetClassNameList( " ispromotion = 1 and proismarket=1  ").Tables[0];// this.cm.GetCategoryByNavigationTypeAndLanguageVersionAndIsShow(2, "zh-CN", 1);
            builder.AppendLine("<div class=\"new_por sales\">");
            builder.AppendLine("<div class=\"info\">");
            builder.AppendLine("<div class=\"info_img_link\">");
            builder.AppendLine("<div class=\"title\">");
            builder.AppendLine("<div class=\"pro_menu\">");
            int num2 = 0;
            int num3 = 0;
            enumerator = table4.Rows.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    current = (DataRow)enumerator.Current;
                    if (num3 < 6)
                    {
                        builder.AppendLine(string.Concat(new object[] { (num2 == 1) ? " | " : "", "<a href=\"/cn/promotion_goods_list.html?cid=", current["typeid"], "\">", current["className"], "</a>" }));
                        num2 = 1;
                        num3++;
                    }
                }
    
           builder.AppendLine("</div>");
            builder.AppendLine("<p><span class=\"t_name_1\">促销专区</span><span class=\"t_name_2\">PROMOTION</span></p>");
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"box_promotion\">");
            builder.AppendLine("<div class=\"box_promotion_left\">");
            builder.AppendLine("<ul id=\"tabMenu\">");
            num2 = 0;
            num3 = 0;
            enumerator = table4.Rows.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    current = (DataRow)enumerator.Current;
                    if (num3 < 6)
                    {
                        builder.AppendLine(string.Concat(new object[] { "<li ", (num2 == 0) ? "class=\"comments selected\"" : "class=\"comments\"", "><strong>", current["className"], "促销</strong></li>" }));
                        num2 = 1;
                        num3++;
                    }
                }
            
            builder.AppendLine("</ul>");
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"boxBody\">");
            int num4 = 1;
            enumerator = table4.Rows.GetEnumerator();
            
                while (enumerator.MoveNext())
                {
                    current = (DataRow)enumerator.Current;
                    builder.AppendLine(string.Concat(new object[] { "<div id=\"comments", num4, "\" ", (num4 == 1) ? "class=\"show\"" : "", ">" }));
                    builder.AppendLine("<ul class=\"l_two\">");
                    DataTable table5 = theShoppro.GetList(8, " ispromotion = 1 and proismarket=1 and typeid = " + current["typeid"]).Tables[0];// this.gm.GetGoodsByCategoryAndIsShelvesAndIsPromoteAndTop(current["id"].ToString(), 1, 8, 1);
                    foreach (DataRow row2 in table5.Rows)
                    {
                        string picUrl = System.Configuration.ConfigurationManager.AppSettings["ProductUrl"] + row2["prosmallpic"];
                        builder.AppendLine("<li>");
                        builder.AppendLine(string.Concat(new object[] { "<a href=\"/cn/goods.html?id=", row2["proid"], "\" title=\"", row2["proname"], "\"><img style=\"width:122px; height:122px;\" src=\"", picUrl, "\" alt=\"", row2["proname"], "\" /></a>" }));
                        builder.AppendLine(string.Concat(new object[] { "<p align=\"center\"><a href=\"/cn/goods.html?id=", row2["proid"], "\" title=\"", row2["proname"], "\">", (row2["proname"].ToString().Length > 8) ? (row2["proname"].ToString().Substring(0, 8) + "...") : row2["proname"].ToString(), "</a><br /><span class=\"red\">促销价", string.Format("{0:C}", Convert.ToDecimal(row2["marketprice"])), "</span></p>" }));
                        builder.AppendLine("</li>");
                    }
                    builder.AppendLine("</ul>");
                    builder.AppendLine("</div>");
                    num4++;
                }
            
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"info_link\">");
            builder.AppendLine("<div class=\"title\">");
            builder.AppendLine("<p><a class=\"more\" href=\"/cn/points_for_list.html\" title=\"查看更多\">查看更多>>></a><span class=\"t_name_1\">今日团购推荐</span></p>");
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"JDSHleft\">");
            DataTable pointsForByRowsAndLanguageVersion = this.pfm.GetPointsForByRowsAndLanguageVersion(9, "zh-CN");
            for (num5 = 0; num5 < pointsForByRowsAndLanguageVersion.Rows.Count; num5++)
            {
                DataRow row3 = pointsForByRowsAndLanguageVersion.Rows[num5];
                builder.AppendLine(string.Concat(new object[] { "<div id=\"JDSH", num5 + 1, "\" onmouseover=\"setContentTab('JDSH',", num5 + 1, ",", pointsForByRowsAndLanguageVersion.Rows.Count, ")\" ", (num5 == 0) ? "class='hover'" : "", ">" }));
                builder.AppendLine("<h3>" + (num5 + 1) + "</h3>");
                builder.AppendLine("<h4>" + row3["name"] + "</h4>");
                builder.AppendLine("</div>");
                builder.AppendLine(string.Concat(new object[] { "<div id=\"con_JDSH_", num5 + 1, "\" class=\"JDSHmenuCon\" ", (num5 > 0) ? "style='display: none;'" : "", ">" }));
                builder.AppendLine(string.Concat(new object[] { "<img src=\"", row3["image"], "\" alt=\"", row3["name"], "\" /><input style=\"cursor:pointer;\" type=\"button\" value=\"立即交换\" onclick=\"pointsFor('", row3["id"], "','", row3["exchangePoints"], "');\">" }));
                builder.AppendLine("<p>所需积分<strong>" + row3["exchangePoints"] + "</strong></p>");
                builder.AppendLine("</div>");
            }
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            builder.AppendLine("</div>");
            builder.AppendLine("<div class=\"clear\"></div>");
            builder.AppendLine("</div>");
            DataTable table7 = theClass.GetMenuList(1);// this.cm.GetCategoryByNavigationTypeAndLanguageVersionAndIsShow(3, "zh-CN", 1);
            int num6 = 0;
            for (num5 = 0; num5 < table7.Rows.Count; num5++)
            {
                current = table7.Rows[num5];
                DataTable table8 ;// = this.gm.GetGoodsByCategoryAndIsShelvesAndTop(current["id"].ToString(), 1, 7);
                if (current["classname"].ToString().Contains("专区"))
                {
                    table8 = theShoppro.GetList(7, " proisprofession = 1").Tables[0];
                }
                else if (current["classname"].ToString().Contains("商城"))
                {
                    table8 = theShoppro.GetList(7, " proismarket = 1").Tables[0];
                } else 
                {
                    table8 = theShoppro.GetList(7, " proiscard = 1").Tables[0];
                }
                if (table8 != null)
                {
                    if (table8.Rows.Count > 0)
                    {
                        if (num6 == 2)
                        {
                            XmlElement element2 = (XmlElement)document.SelectSingleNode("home_ad/middle");
                            builder.AppendLine("<div class=\"banner_02\"><a href=\"" + element2.GetAttribute("url") + "\"><img src=\"" + element2.GetAttribute("src") + "\" alt=\"" + element2.GetAttribute("alt") + "\" /></a></div>");
                        }
                        builder.AppendLine("<div class=\"new_por\">");
                        builder.AppendLine("<div class=\"title\">");
                        builder.AppendLine("<div class=\"pro_menu\"><a href=\"goods_list.html?cid=" + current["classid"] + "\" title=\"查看更多\">查看更多>>></a></div>");
                        builder.AppendLine("<p><span class=\"t_name_1\">" + current["className"] + "</span></p>");
                        builder.AppendLine("</div>");
                        builder.AppendLine("<div class=\"info\">");
                        XmlElement element3 = (XmlElement)document.SelectSingleNode("home_ad/category_ad").ChildNodes[num5];
                        builder.AppendLine("<a href=\"" + element3.GetAttribute("url") + "\" class=\"banner_01\"><img src=\"" + element3.GetAttribute("src") + "\" alt=\"" + element3.GetAttribute("alt") + "\" /></a>");
                        builder.AppendLine("<div class=\"info_list\">");
                        builder.AppendLine("<ul>");
                        foreach (DataRow row4 in table8.Rows)
                        {
                            string picUrl = System.Configuration.ConfigurationManager.AppSettings["ProductUrl"] + row4["prosmallpic"];
                            builder.AppendLine("<li>");
                            builder.AppendLine(string.Concat(new object[] { "<a href=\"/cn/goods.html?id=", row4["proid"], "\" name=\"#hoverinfo", row4["proid"], "\" class=\"pro_img\"><img alt=\"", row4["proname"], "\" src=\"", picUrl, "\" /></a>" }));
                            builder.AppendLine(string.Concat(new object[] { "<p><a href=\"/cn/goods.html?id=", row4["proid"], "\">", (row4["proName"].ToString().Length > 8) ? (row4["proName"].ToString().Substring(0, 8) + "...") : row4["proName"], "</a><span>市场价", string.Format("{0:C}", Convert.ToDecimal(row4["saleprice"])), "</span><em>会员价：<strong>", string.Format("{0:C}", Convert.ToDecimal(row4["marketprice"])), "</strong></em></p>" }));
                            builder.AppendLine(string.Concat(new object[] { "<div id=\"hoverinfo", row4["proid"], "\" style=\"display: none;\"><img src=\"", picUrl , "\" alt=\"", row4["proName"], "\" /><p><strong>", row4["proname"], "</strong> <span>产品编号:", row4["procode"], "</span> <span>会员价：<em>", string.Format("{0:C}", Convert.ToDecimal(row4["marketprice"])), "</em></span><span><del>市场价", string.Format("{0:C}", Convert.ToDecimal(row4["saleprice"])), "</del></span></p></div>" }));
                            builder.AppendLine("</li>");
                        }
                        builder.AppendLine("</ul>");
                        builder.AppendLine("<div class=\"clear\"></div>");
                        builder.AppendLine("</div>");
                        builder.AppendLine("</div>");
                        builder.AppendLine("</div>");
                        num6++;
                    }
                }
            }
        }
        catch
        {
        }
        return builder;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

}